package com.candy.control;

import com.candy.bean.UserInfo;
import com.candy.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin
public class LoginController {
    @Autowired
    LoginService loginService;
    @RequestMapping("/login")
    public String login(UserInfo userinfo){
//        调用业务逻辑处理层，比对用户名密码
        boolean ok=loginService.login(userinfo);
//        若返回true,表示用户名密码匹配成功,则响应ok,反之返回eg
        if(ok){
            return "ok";
        }else {
            return "eg";
        }


    }
}
